package cn.tedu.rabbitmqboot.m1;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Producer {
    @Autowired
    private AmqpTemplate amqpTemplate;

    // 需要手动调用,发送消息
    public void send(){
        // 字符串自动转成 byte[] 数组, 在发送到helloworld队列
        amqpTemplate.convertAndSend("helloworld", "Hello World!");
        System.out.println("消息已发送");
    }


}
